#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/6/17 9:54
# @Author : 闫峰
# @File    : dynamic_inventory.py


from typing import Optional

from common.setting import ensure_path_sep
from utils.mysqlUtils.db_pool import Database

zhcxkj_center_warehouse_db = Database(ensure_path_sep("\\config\\shopeev2_config.yaml.bak"),
                                                          "HWY-ZH-GZ-RDS-Warehouse")


class DynamicInventory:

    @staticmethod
    def get_sku_list():

        # 构造SQL查询语句，用于从综合列表数据库中分批获取产品信息
        filter = """
        SELECT
         sku
        FROM
        	`zhcxkj-center-warehouse`.dynamic_inventory 
        WHERE
        	 update_date >= DATE_SUB(now(),INTERVAL 30 MINUTE) 
            """
        data_list = zhcxkj_center_warehouse_db.fetch_all_tuple(filter, ())
        if not len(data_list):
            return []
        return list(map(lambda x:x[0],data_list))